package Model
{
	
	[Bindable]
	public class Post
	{
		protected var _ID:Number;
		protected var _author:User;
		protected var _topic:Topic;
		protected var _text:String;
		protected var _currentDate:Date;
		protected var _changed:Boolean;

		
		public function Post(id:Number, author:User, topic:Topic, currentDate:Date, text:String = "", changed:Boolean = false)
		{
			this._ID = id;
			this._author = author;
			this._topic = topic;
			this._text = text;
			this._currentDate = currentDate;
			this._changed = changed;
		}
		
		public function get ID():Number
		{
			return _ID;
		}
		
		
		public function getAuthorFirstName():String
		{
			return _author.FirstName;
		}
		
		public function getAuthorLastName():String
		{
			return _author.LastName;
		}
		
		public function getAuthorCallName():String
		{
			return _author.CallName;
		}
		
		public function get topic():Topic
		{
			return _topic;
		}
		
		public function getPostTopicName():String
		{
			return _topic.TopicName;
		}
		
		public function get text():String
		{
			return _text;
		}
		
		public function get changed():Boolean
		{
			return _changed;
		}
		
		public function get getCurrentDate():Date
		{
			return this._currentDate;
		}
		
		
		public function getTime():String
		{
		var currentTime:String;	
		if(_currentDate.getMinutes()>= 10)	
		    currentTime = _currentDate.getHours().toString()+ ":"+ _currentDate.getMinutes();
		else
			currentTime = _currentDate.getHours().toString()+ ":0"+ _currentDate.getMinutes();
		return currentTime;
		}	
		
		public function set text(newText:String):void
		{
			_text = newText;
		}
		
		public function set topic(topic:Topic):void
		{
			_topic = topic;
		}
		
		public function set changed(changed:Boolean):void
		{
			_changed = changed
		}
		
		
		
	}
}